﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Text;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Data;


namespace IHISCETeim.Web.MachineSys.MacModel
{
    public partial class ExeclOCompletingCheckList : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "OCompletingCheckList";
            }
        }


        private SerializableDictionary<string, XRJCItem> _XRJCDict = null;
        protected DataTable GetDt()
        {
            DataTable dt = new DataTable();
            string[] strItems = Enum.GetNames(typeof(XRJCEnum));
            dt.Columns.Add(new DataColumn("机号",typeof(string)));
            foreach (string str in strItems)
            {
                DataColumn dc = new DataColumn(str,typeof(string));
                dt.Columns.Add(dc);
            }
            //获取所有的数据
            DataTable soureDT = OCompletingCheckController.GetPagination("", 1, 99999, " MachineType ASC ", ref TotalCount);
            foreach (DataRow soureDR in soureDT.Rows)
            {
                DataRow dr = dt.NewRow();
                dr["机号"] = soureDR["SerialNumber"];

                ///
                _XRJCDict = XmlSerializerHelper.Deserialize<SerializableDictionary<string, XRJCItem>>(soureDR["XNJCITEM"].ToString());
                if (_XRJCDict.Count() <= 0)
                {
                    _XRJCDict = new SerializableDictionary<string, XRJCItem>(CompleteCheckXMLHelper.XRJCDict);
                    SerializableDictionary<string, float> tempdic = XmlSerializerHelper.Deserialize<SerializableDictionary<string, float>>(soureDR["XNJCITEM"].ToString());

                    foreach (var x in tempdic)
                    {
                        XRJCItem tempitem = new XRJCItem();
                        tempitem.Key = x.Key;
                        tempitem.Value = x.Value.ToString();
                        tempitem.NGValue = "ok";
                        _XRJCDict[x.Key] = tempitem;

                        //tempdic[x.Key] = HttpContext.Current.Request.GetRequestValue<float>(x.Key);
                    }
                }

                ///

               // SerializableDictionary<string, float> tempdic = XmlSerializerHelper.Deserialize<SerializableDictionary<string, float>>(soureDR["XNJCITEM"].ToString());

                foreach (var x in _XRJCDict)
                {
                    dr[x.Value.Key] = x.Value.Value.ToString();                  
                }



                dt.Rows.Add(dr);
            }
            return dt;
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            rpMenu.AutoGenerateColumns = true;
            rpMenu.DataSource = GetDt();
            rpMenu.DataBind();

            ExportToExecl("完成检查书_性能检测项值导出", this.rpMenu);
        }
        

    }
}